<p-table [columns]="model.cols" [value]="model.data" [loading]="model?.loading"
         [paginator]="pager.enabled" [rows]="pager?.pageSize" [pageLinks]="pager?.pageLinks"
         [rowsPerPageOptions]="pager?.rowsPerPageOptions" [totalRecords]="pager?.totalCount"
         [lazy]="true" (onLazyLoad)="loadLazy($event)">
  <ng-template pTemplate="caption">
    <div class="text-left">
      <button pButton *ngFor="let btn of buttons?.listTopButtons" [title]="btn.buttonTitle" (click)="btnClick(btn)"  [icon]="btn.icon" [class]="btn.buttonClass"></button>
    </div>
  </ng-template>
  <ng-template pTemplate="header" let-columns>
    <tr>
      <th style="width:3em;"></th>
      <th *ngFor="let col of columns"  [ngStyle]="col?.style">
        {{col.header}}
      </th>
      <th *ngIf="buttons?.hasRowButtons">操作</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-item let-columns="columns" let-index="rowIndex">
    <tr [pReorderableRow]="index">
      <td class="text-center">{{index+1}}</td>
      <td>
        <span *ngIf="item.moduleCode.length==4"><i class="{{item.icon}}"></i>&nbsp;{{item.moduleName}}</span>
        <span *ngIf="item.moduleCode.length>4"  style="margin-left: 30px;">[ {{item.moduleName}} ]</span>
      </td>
      <td>
        <span style="color: #0d8ced; text-align: left;padding-left: 10px; width: 300px;">{{item.linkUrl}}</span>
      </td>
      <td style="text-align: center;"><span *ngIf="item.isLeafMenu" class="fa fa-check"></span></td>
      <td pEditableColumn style="padding: 2px 10px; text-align: center;">
        <p-cellEditor>
          <ng-template pTemplate="input">
            <p-checkbox [(ngModel)]="item.enabled" binary="true"></p-checkbox>
          </ng-template>
          <ng-template pTemplate="output">
            <span *ngIf="item.enabled" class="fa fa-check"></span>
          </ng-template>
        </p-cellEditor>
      </td>
      <td pEditableColumn style="padding: 2px 10px;">
          <p-cellEditor>
            <ng-template pTemplate="input">
              <input pInputText type="text" [(ngModel)]="item.sortNo">
            </ng-template>
            <ng-template pTemplate="output">
              {{ item.sortNo }}
            </ng-template>
          </p-cellEditor>
      </td>
      <td>
        <button pButton *ngFor="let btn of buttons?.listRowButtons" (click)="btnClick(btn,item)"
                [title]="btn.functionName" [icon]="btn.icon" class="row-btn {{btn.buttonClass}}"></button>
      </td>
    </tr>
  </ng-template>
</p-table>
